package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/consumer")
/*@DefaultProperties(defaultFallback="paymentInfo_timeout_handler",
		commandProperties = {
				@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "1500")
		}
)*/
public class OrderController {
	
	@Autowired
	private PaymentService paymentService;
	
	@GetMapping("/payment/ok")
	public String paymentInfo_ok(){
		return paymentService.paymentInfo_ok();
	}
	
	
	@GetMapping("/payment/timeout")
	//@HystrixCommand
	public String paymentInfo_timeout(){
		return paymentService.paymentInfo_timeout();
	}
	
	public String paymentInfo_timeout_handler(){
		String info = "出错了!!!";
		log.info(info);
		return info;
	}
}
